<?php
require_once __DIR__ . '/vendor/autoload.php';

use PhpAmqpLib\Connection\AMQPStreamConnection;

$connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest', '/');
$channel = $connection->channel();

$channel->queue_declare('job', false, false, false, false);

echo "Waiting Receiving Messages\n";

$callback = function ($msg) {
    echo $msg->body . "\n";
};

$channel->basic_consume('job', '', false, true, false, false, $callback);

while (count($channel->callbacks)) {
    $channel->wait();
}
